// ANES20PubOp

log using ANES20PubOp.log, replace

use "C:\Users\sbstjp\OneDrive - Cardiff University\anes_timeseries_2020_stata_20220210.dta" // American National Election Study 2020 Time Series Study, Feb 10, 2022 Version. Date accessed: March 09, 2025. Accessed from https://electionstudies.org/data-center/2020-time-series-study/

// Delete interview breakoff from the questions and rename
rename V201411x tgpolicy 
rename V201626 offence 
replace offence = . if offence==-5

// Demographic variables
* Delete missing values
rename V201507x age 
replace age = . if age == -9

rename V201600 FemaleGender 
replace FemaleGender = . if FemaleGender == -9

rename V201510 education 
replace education = . if inlist(education, -9, -8, 95)

rename V201549x race
replace race = . if inlist(race, -9, -8)

rename V201200 libconsp 
replace libconsp = . if inlist(libconsp, -9, -8, 99)

*Create dummy variables
gen Graduate=.
replace Graduate=0 if education<6
replace Graduate=1 if inrange(education, 6, 8)

gen BIPOC=. 
replace BIPOC=0 if race==1
replace BIPOC=1 if inrange(race, 2, 6)

// The results
tab tgpolicy [aweight=V200010a]
tab tgpolicy if libconsp < 4 [aweight=V200010a]
tab tgpolicy if libconsp > 4 [aweight=V200010a]
tab tgpolicy if Graduate==0 [aweight=V200010a]
tab tgpolicy if Graduate==1 [aweight=V200010a]
tab tgpolicy if BIPOC==0 [aweight=V200010a]
tab tgpolicy if BIPOC==1 [aweight=V200010a]
tab tgpolicy if FemaleGender==1 [aweight=V200010a]
tab tgpolicy if FemaleGender==2 [aweight=V200010a]
tab tgpolicy if age<35 [aweight=V200010a]
tab tgpolicy if age>=35 & age<=59 [aweight=V200010a]
tab tgpolicy if age>59 [aweight=V200010a]

tab offence [aweight=V200010a]
tab offence if libconsp < 4 [aweight=V200010a]
tab offence if libconsp > 4 [aweight=V200010a]
tab offence if Graduate==0 [aweight=V200010a]
tab offence if Graduate==1 [aweight=V200010a]
tab offence if BIPOC==0 [aweight=V200010a]
tab offence if BIPOC==1 [aweight=V200010a]
tab offence if FemaleGender==1 [aweight=V200010a]
tab offence if FemaleGender==2 [aweight=V200010a]
tab offence if age<35 [aweight=V200010a]
tab offence if age>=35 & age<=59 [aweight=V200010a]
tab offence if age>59 [aweight=V200010a]

log close
